package com.tyc.async;

import java.util.Map;
import java.util.Set;

/**
 * 类描述
 *
 * @author tyc
 * @version 1.0
 * @date 2023-03-09 13:45:44
 */
public class Test {
    public static void main(String[] args) {
        Master master = new Master(new PlusWorker(), 5);
        for (int i = 0; i <= 100; i++) {
            master.submit(i);
        }
        master.execute();
        int result = 0;
        Map<String, Object> resultMap = master.getResultMap();
        while (resultMap.size()>0 || !master.isComplete()){
            String key=null;
            Set<String> keys=resultMap.keySet();
            for(String k:keys){
                key=k;
                break;
            }
            Integer i=null;
            if(key!=null){
                i=(Integer)resultMap.get(key);
                resultMap.remove(key);
            }
            if(i!=null){
                result+=i;
            }
        }
        System.out.println(result);
    }
}
